package 双指针.复写零;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2025-02-28
 * Time: 21:32
 */
public class my {
    public static void main(String[] args) {
        int[] array={1,0,2,3,0,4,5,0};
        for (int i = 0; i < array.length; i++) {
            if(array[i]==0){
                for (int j = array.length-1; j >=i+2; j--) {
                    array[j]=array[j-1];
                }
                array[i+1]=0;
                i++;
            }
        }
        System.out.println(Arrays.toString(array));
    }
}
